//
//  GiftView.m
//  YouinRTCDemo
//
//  Created by super on 2021/12/23.
//

#import "GiftView.h"

@implementation GiftView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
    }
    return self;
}


-(void)setUI{
    
    self.name = [[UIFactory shareInstace] setLabel:CGRectMake(16, 15, 171, 16) text:@"" font:[UIFont systemFontOfSize:16] textColor:[UIColor whiteColor]];
    self.giftName = [[UIFactory shareInstace] setLabel:CGRectMake(16, 40, 171, 15) text:@"" font:[UIFont systemFontOfSize:16] textColor:[UIColor whiteColor]];
    self.gift = [[UIImageView alloc] initWithFrame:CGRectMake(187.5, 15, 40, 40)];
    self.gift.contentMode = UIViewContentModeScaleAspectFit;
    
    [self addSubview:self.name];
    [self addSubview:self.giftName];
    [self addSubview:self.gift];
   
}

- (void)setModel:(BaseMessageModel *)model{
    
    self.name.textColor =  rgba(arc4random() % 256, arc4random() % 256, arc4random() % 256, 1);
    self.name.text = model.nickName;
    self.giftName.text = [NSString stringWithFormat:@"赠送了 %@x%d",model.giftName,model.giftCount];
    [self.gift sd_setImageWithURL:[NSURL URLWithString:model.giftUrl]];
}

@end


